package com.ideabove.adapter;

import java.util.ArrayList;
import java.util.List;

import com.ideabove.radio.R;
import com.ideabove.util.img.ImageLoader;
import com.ideabove.data.Channel;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ChannelAdapter extends BaseAdapter
{

	private List<Channel> mList;
	private LayoutInflater mInflater;    

	public ChannelAdapter(Context c , ArrayList<Channel> arrays){
		this.mInflater = LayoutInflater.from(c);
		this.mList = arrays;
	}

	int index = 0;

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		Channel channel = mList.get(position);
		
//		Log.e("#########", "postion:" + position);

		if(convertView == null)
		{
			convertView = mInflater.inflate(R.layout.list_channel_row, null);								
		}
		
		TextView content = (TextView) convertView.findViewById(R.id.ch_desc);
		content.setText(channel.getDj_title());
		
		ImageView imageView = (ImageView) convertView.findViewById(R.id.ch_image);
		ImageLoader.download(channel.getImg_path(), imageView);

		return convertView;
	}



	@Override
	public int getCount() {
		return mList.size();
	}
	@Override
	public Channel getItem(int position) {
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

}
